package com.jade.framework.web.security;

import java.security.Permission;
import java.util.HashMap;
import java.util.Map;

import com.jade.framework.base.security.PermissionService;

/**
 * 根据权限名称简单的返回相应的权限。
 *
 * @author Daisy
 * @version 1.0 14-10-7 下午11:41
 */
public class SimplePermissionService
        implements PermissionService
{
    private Map<String, Permission> permissionMap = new HashMap<String, Permission>();

    public void setPermissionMap(Map<String, Permission> permissionMap)
    {
        this.permissionMap = permissionMap;
    }

    public Permission getPermission(String name)
    {
        Permission permission = permissionMap.get(name);
        if (permission == null) {
            permission = new RolePermission(name);
            permissionMap.put(name, permission);
        }
        return permission;
    }

}
